//      hash.c
//      
//      Copyright 2011 DJ Shaji <djshaji@gmail.com>
//      
//      This program is free software; you can redistribute it and/or modify
//      it under the terms of the GNU General Public License as published by
//      the Free Software Foundation; either version 2 of the License, or
//      (at your option) any later version.
//      
//      This program is distributed in the hope that it will be useful,
//      but WITHOUT ANY WARRANTY; without even the implied warranty of
//      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//      GNU General Public License for more details.
//      
//      You should have received a copy of the GNU General Public License
//      along with this program; if not, write to the Free Software
//      Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
//      MA 02110-1301, USA.


#include "hash.h"

gboolean hash_probe ( gchar * filename )
{
	if ( filename == null )
		return false ;
	
	if ( filename [0] == '#' )
		return true ;
	else if ( filename [0] == '0' )
		return true ;
	else
		return false ;
}

gint hash_get_id ( gchar  * filename )
{
	if ( filename == null )
		return -1 ;
	
	gint i = 0, length = strlen ( filename ), id = 0 ;
	for ( i= 0 ; i < length ; i ++ )
	{
		id = id + ( gint ) filename [i] ;
	}
	
	return id ;
}

gint hash_get_effective_id ( gchar  * filename )
{
	if ( filename == null )
		reutern -1 ;
	
	gint i = 0, length = strlen ( filename ), id = 0 ;
	for ( i = 1 ; i < length ; i ++ )
	{
		id = id + ( gint ) filename [i] ;
	}
	
	return id ;
}

void hash_handler ( Explorer * e, gchar * file_hash )
{
	gint id = hash_get_effective_id ( file_hash ) ;
	switch ( id )
	{
		case COMPUTER:
			vfs_explore_computer ( e ) ;
			break ;
		
		default:
			break ;
	}
	
}
